﻿<?php 
error_reporting(0);
include 'excel_reader.php';
include 'conn.php';
include 'common.php';?>
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>查找学生</title>
<body>
<div class="container">
<div class="nav_header">
<?php include 'head.php';?>
</div>
<div class="main_cj_content">	

<p class="welcome">查找结果:</p>
<hr>
<br />
<br />
<?php
if($_POST['username'])
{
	$username=getpost('username');
	$exe="select * from users where username like '%".$username."%' or realname like '%".$username."%' and user_category <>3";
	
   $rs=mysql_query($exe);
   echo "<table border=1 class='search_result'><tr><td>用户账户</td><td>用户类别</td><td>用户真实姓名</td><td>用户所在班级</td><td>操作</td></tr>";
   while ($row=mysql_fetch_array($rs))
   {
   	$username=$row['username'];
   	switch ($row['user_category'])
   	{
   	case 1:
   		$user_category="学生";
   	break;
   	case 2:
   		$user_category="老师";
   	}
   $realname=$row['realname'];
   $class=$row['class'];
   
   	echo "<tr><td>$username</td><td>$user_category</td><td>$realname</td><td>$class</td></td>";
   }
   echo "</table>";
}
else
{
	$exe="select * from users where user_category < 3 ";
	$rs=mysql_query($exe);
	echo "<table border=1 class='search_result'><tr><td>用户账户</td><td>用户类别</td><td>用户真实姓名</td><td>用户所在班级</td></tr>";
	while ($row=mysql_fetch_array($rs))
	{
		$username=$row['username'];
		switch ($row['user_category'])
		{
			case 1:
				$user_category="学生";
				break;
			case 2:
				$user_category="老师";
		}
		$realname=$row['realname'];
		$class=$row['class'];
		 
		echo "<tr><td>$username</td><td>$user_category</td><td>$realname</td><td>$class</td></td>";
	}
	echo "</table>";
}
